package org.cboard.services;

import org.apache.commons.lang.StringUtils;
import org.cboard.dao.MapInfoDao;
import org.cboard.pojo.DashboardMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xiang on 2017/2/10.
 */
@Service
public class MapInfoService {

    @Autowired
    private MapInfoDao mapInfoDao;

    public List<DashboardMap> getChildMapList(String req_id){
        List<DashboardMap> list = new ArrayList<>();
        if (StringUtils.isBlank(req_id)){
            DashboardMap map = new DashboardMap();
            map.setName("china");
            list.add(map);
        }else {
            try {
                Long id = "china".equals(req_id) ?  0 : Long.parseLong(req_id);
                list = mapInfoDao.getChildMapList(id);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return list;
    }

}
